package wxact

import (
	"myproject/wx_test/src/wxmod"
	"strconv"
	"time"
)

type WXActXML struct{}

func (*WXActXML) DefaultResp(msgRec *wxmod.XmlData) string {
	t := strconv.FormatInt(time.Now().Unix(), 10)

	msgSend := `"<xml><ToUserName><![CDATA[` + msgRec.FromUserName + `]]></ToUserName>
	<FromUserName><![CDATA[` + msgRec.ToUserName + `]]></FromUserName>
	<CreateTime>` + t + `</CreateTime>
	<MsgType><![CDATA[text]]></MsgType>
	<Content><![CDATA[success]]></Content>
	</xml>"`

	return msgSend
}

func (*WXActXML) RespTextMsg(msgRec *wxmod.XmlData) string {
	t := strconv.FormatInt(time.Now().Unix(), 10)

	msgSend := `"<xml><ToUserName><![CDATA[` + msgRec.FromUserName + `]]></ToUserName>
	<FromUserName><![CDATA[` + msgRec.ToUserName + `]]></FromUserName>
	<CreateTime>` + t + `</CreateTime>
	<MsgType><![CDATA[text]]></MsgType>
	<Content><![CDATA[` + msgRec.Content + `]]></Content>
	</xml>"`

	return msgSend
}

func (*WXActXML) RespNewsMsg(msgRec *wxmod.XmlData) string {
	t := strconv.FormatInt(time.Now().Unix(), 10)

	msgSend := `"<xml>
	<ToUserName><![CDATA[` + msgRec.FromUserName + `]]></ToUserName>
	<FromUserName><![CDATA[` + msgRec.ToUserName + `]]></FromUserName>
	<CreateTime>` + t + `</CreateTime>
	<MsgType><![CDATA[news]]></MsgType>
	<ArticleCount>2</ArticleCount>
	<Articles>
	<item>
	<Title><![CDATA[WELCOME]]></Title>
	<Description><![CDATA[description1]]></Description>
	<PicUrl><![CDATA[https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497552821226&di=530d12f7409be47ab4545228b14c8665&imgtype=0&src=http%3A%2F%2Fs-2.caoxie.com%2F2017%2F5%2F22%2F9e5613c8-5a45-4f4e-a887-3d73b2060c5c.jpg]]></PicUrl>
	<Url><![CDATA[https://wx.iyuedan.com/wap/share/FriendGet?uid=55937325&type=2&user_id=55702289&source=weixin]]></Url>
	</item>
	<item>
	<Title><![CDATA[WELCOME2]]></Title>
	<Description><![CDATA[description2]]></Description>
	<PicUrl><![CDATA[https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497552911967&di=3802a9d24c3e0af11127eeb772242185&imgtype=0&src=http%3A%2F%2Fepaper.xkb.com.cn%2Fdata%2Fxkbimg%2F2017%2F20170525%2FA25_6448896_kmggcd_1495622010771_s.jpg]]></PicUrl>
	<Url><![CDATA[https://wx.iyuedan.com/wap/share/FriendGet?uid=55937325&type=2&user_id=55702289&source=weixin]]></Url>
	</item>
	</Articles>
	</xml>"`

	return msgSend
}

func (*WXActXML) RespImgMsg(msgRec *wxmod.XmlData) string {
	t := strconv.FormatInt(time.Now().Unix(), 10)

	msgSend := `"<xml><ToUserName><![CDATA[` + msgRec.FromUserName + `]]></ToUserName>
	<FromUserName><![CDATA[` + msgRec.ToUserName + `]]></FromUserName>
	<CreateTime>` + t + `</CreateTime>
	<MsgType><![CDATA[image]]></MsgType>
	<Image>
	<MediaId><![CDATA[media_id]]></MediaId>
	</Image>
	</xml>"`

	return msgSend
}
